@zonos/elements 1.3.122 → 1.3.124

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/cjs/{CheckoutConfig-00c7333a.js → CheckoutConfig-8e3cdcb3.js} +1 -1
  2. package/dist/cjs/{cart-0e01d134.js → cart-a2a94f35.js} +21 -15
  3. package/dist/cjs/{handleFetch-83c97d08.js → handleFetch-fa0ce321.js} +5 -1
  4. package/dist/cjs/index.cjs.js +9 -9
  5. package/dist/cjs/{paypal-f1366d51.js → paypal-bf7d3c50.js} +2 -2
  6. package/dist/cjs/zonos-address_7.cjs.entry.js +2 -2
  7. package/dist/cjs/zonos-cart-items_13.cjs.entry.js +3 -3
  8. package/dist/cjs/zonos-checkout.cjs.entry.js +5 -4
  9. package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
  10. package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
  11. package/dist/cjs/zonos-country-select_4.cjs.entry.js +2 -2
  12. package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
  13. package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
  14. package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
  15. package/dist/cjs/zonos-notification_3.cjs.entry.js +3 -3
  16. package/dist/collection/__tests__/build-utils/urlCheckOne.js +7 -15
  17. package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +2 -1
  18. package/dist/collection/components/store/checkout/stripe.js +19 -14
  19. package/dist/collection/components/utils/handleFetch.js +5 -1
  20. package/dist/esm/{CheckoutConfig-5cde3ee4.js → CheckoutConfig-101b97e6.js} +1 -1
  21. package/dist/esm/{cart-782d513d.js → cart-7d97dbff.js} +21 -16
  22. package/dist/esm/{handleFetch-7424d200.js → handleFetch-da1a9c5d.js} +5 -1
  23. package/dist/esm/index.js +10 -10
  24. package/dist/esm/{paypal-7df6311e.js → paypal-7264946a.js} +2 -2
  25. package/dist/esm/zonos-address_7.entry.js +2 -2
  26. package/dist/esm/zonos-cart-items_13.entry.js +3 -3
  27. package/dist/esm/zonos-checkout.entry.js +5 -4
  28. package/dist/esm/zonos-controller.entry.js +2 -2
  29. package/dist/esm/zonos-country-flag.entry.js +2 -2
  30. package/dist/esm/zonos-country-select_4.entry.js +2 -2
  31. package/dist/esm/zonos-hello-dialog.entry.js +2 -2
  32. package/dist/esm/zonos-hello.entry.js +2 -2
  33. package/dist/esm/zonos-language-select_2.entry.js +2 -2
  34. package/dist/esm/zonos-notification_3.entry.js +3 -3
  35. package/dist/esm-es5/{CheckoutConfig-5cde3ee4.js → CheckoutConfig-101b97e6.js} +1 -1
  36. package/dist/esm-es5/{cart-782d513d.js → cart-7d97dbff.js} +1 -1
  37. package/dist/esm-es5/{handleFetch-7424d200.js → handleFetch-da1a9c5d.js} +1 -1
  38. package/dist/esm-es5/index.js +1 -1
  39. package/dist/esm-es5/{paypal-7df6311e.js → paypal-7264946a.js} +1 -1
  40. package/dist/esm-es5/zonos-address_7.entry.js +1 -1
  41. package/dist/esm-es5/zonos-cart-items_13.entry.js +1 -1
  42. package/dist/esm-es5/zonos-checkout.entry.js +1 -1
  43. package/dist/esm-es5/zonos-controller.entry.js +1 -1
  44. package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
  45. package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
  46. package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
  47. package/dist/esm-es5/zonos-hello.entry.js +1 -1
  48. package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
  49. package/dist/esm-es5/zonos-notification_3.entry.js +1 -1
  50. package/dist/scripts/index.js +1 -1
  51. package/dist/scripts/loadZonos.js +1 -1
  52. package/dist/scripts/zonos.js +1 -1
  53. package/dist/types/__tests__/build-utils/urlCheckOne.d.ts +1 -3
  54. package/dist/types/components/store/checkout/stripe.d.ts +2 -1
  55. package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
  56. package/dist/zonos-elements/index.esm.js +1 -1
  57. package/dist/zonos-elements/{p-bbddbf97.system.entry.js → p-02c97b12.system.entry.js} +1 -1
  58. package/dist/zonos-elements/{p-1b240438.system.entry.js → p-073bcd19.system.entry.js} +1 -1
  59. package/dist/zonos-elements/{p-81055154.system.js → p-0fa85ff9.system.js} +1 -1
  60. package/dist/zonos-elements/{p-2cb215fd.entry.js → p-1a7975a6.entry.js} +1 -1
  61. package/dist/zonos-elements/{p-100dc75c.entry.js → p-2763b93b.entry.js} +1 -1
  62. package/dist/zonos-elements/{p-bce88a97.entry.js → p-3251fb8b.entry.js} +1 -1
  63. package/dist/zonos-elements/{p-86d875a8.system.entry.js → p-4afde7ca.system.entry.js} +1 -1
  64. package/dist/zonos-elements/{p-91a332f3.system.entry.js → p-68f30f18.system.entry.js} +1 -1
  65. package/dist/zonos-elements/{p-19d75216.entry.js → p-6cc6c6c4.entry.js} +1 -1
  66. package/dist/zonos-elements/p-71a733d4.system.entry.js +1 -0
  67. package/dist/zonos-elements/p-7769b60c.js +1 -0
  68. package/dist/zonos-elements/{p-22cb3fa7.js → p-78adf768.js} +1 -1
  69. package/dist/zonos-elements/{p-d8e9e915.entry.js → p-8138eb01.entry.js} +1 -1
  70. package/dist/zonos-elements/{p-0a5d1db8.entry.js → p-8333a565.entry.js} +1 -1
  71. package/dist/zonos-elements/{p-f12c1c1a.entry.js → p-861ed8e9.entry.js} +1 -1
  72. package/dist/zonos-elements/{p-5e6b1a44.entry.js → p-8b1f00a6.entry.js} +1 -1
  73. package/dist/zonos-elements/{p-05820096.system.entry.js → p-8dd3b09d.system.entry.js} +1 -1
  74. package/dist/zonos-elements/{p-5834b65d.system.js → p-8e833a0c.system.js} +1 -1
  75. package/dist/zonos-elements/{p-fcb2227b.js → p-9368629a.js} +1 -1
  76. package/dist/zonos-elements/{p-75d4bd5f.system.entry.js → p-9c7618b3.system.entry.js} +1 -1
  77. package/dist/zonos-elements/{p-850b0e2a.system.entry.js → p-a17ebf04.system.entry.js} +1 -1
  78. package/dist/zonos-elements/{p-8e317f73.js → p-a3b195e9.js} +1 -1
  79. package/dist/zonos-elements/{p-80919c61.system.entry.js → p-ab4d2507.system.entry.js} +1 -1
  80. package/dist/zonos-elements/p-c78dd680.system.js +1 -1
  81. package/dist/zonos-elements/p-c8f24421.entry.js +1 -0
  82. package/dist/zonos-elements/{p-36cfebe1.entry.js → p-d2ca12ed.entry.js} +1 -1
  83. package/dist/zonos-elements/{p-bc2efe24.system.js → p-d9dceba1.system.js} +1 -1
  84. package/dist/zonos-elements/{p-e50eaf44.system.js → p-db6be6ab.system.js} +1 -1
  85. package/dist/zonos-elements/{p-daac8c76.system.entry.js → p-e23684e2.system.entry.js} +1 -1
  86. package/dist/zonos-elements/{p-78887e65.system.js → p-f399a2e5.system.js} +1 -1
  87. package/dist/zonos-elements/zonos-elements.esm.js +1 -1
  88. package/package.json +1 -1
  89. package/dist/zonos-elements/p-05839a81.system.entry.js +0 -1
  90. package/dist/zonos-elements/p-878e3c68.entry.js +0 -1
  91. package/dist/zonos-elements/p-f3cdaa23.js +0 -1
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const handleFetch = require('./handleFetch-83c97d08.js');
3
+ const handleFetch = require('./handleFetch-fa0ce321.js');
4
4
 
5
5
  const getTempCartById = async ({ cartId, retries, }) => {
6
6
  const urlParams = new URLSearchParams(window.location.search);
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const zonosStore = require('./zonosStore-e12d459c.js');
4
- const handleFetch = require('./handleFetch-83c97d08.js');
4
+ const handleFetch = require('./handleFetch-fa0ce321.js');
5
5
  const isDarkColor = require('./isDarkColor-d206c6fa.js');
6
6
  const getBorderRadius = require('./getBorderRadius-61ed5601.js');
7
7
 
@@ -9640,7 +9640,7 @@ const getStripeOptions = ({ clientSecret, overrideBorderRadius, overridePrimaryC
9640
9640
  const themeBasedColor = primaryColor && isDarkColor.isDarkColor(primaryColor) ? 'night' : 'flat';
9641
9641
  // if overrideTheme is provided, use it. Otherwise, use theme based on primary color
9642
9642
  const theme = overrideTheme === 'DARK' ? 'night' : 'flat';
9643
- const paypalPaymenType = paypalEnabled ? ['external_paypal'] : [];
9643
+ const paypalPaymentType = paypalEnabled ? ['external_paypal'] : [];
9644
9644
  return {
9645
9645
  appearance: {
9646
9646
  labels: 'floating',
@@ -9655,7 +9655,7 @@ const getStripeOptions = ({ clientSecret, overrideBorderRadius, overridePrimaryC
9655
9655
  colorPrimary: secondaryColor }),
9656
9656
  },
9657
9657
  clientSecret,
9658
- externalPaymentMethodTypes: [...paypalPaymenType],
9658
+ externalPaymentMethodTypes: [...paypalPaymentType],
9659
9659
  locale: localizationStore.selectedLocale,
9660
9660
  };
9661
9661
  };
@@ -10058,18 +10058,9 @@ const stripeStoreConfirmPayment = async () => {
10058
10058
  }
10059
10059
  }
10060
10060
  };
10061
- /**
10062
- * Init checkout session
10063
- * @returns {boolean} whether or not the checkout session is successfully created
10064
- */
10065
- const stripeStoreInitCheckoutSession = async () => {
10066
- var _a, _b;
10061
+ const getCheckoutSessionBody = () => {
10062
+ var _a;
10067
10063
  const total = cartStore.items.reduce((amount, item) => amount + item.amount * item.quantity, 0);
10068
- if (!localizationStore.targetCurrency) {
10069
- handleFetch.logError(`Failed to create checkout session - missing localizationStore.targetCurrency`);
10070
- return false;
10071
- }
10072
- stripeStore.isFetchingSession = true;
10073
10064
  const body = {
10074
10065
  adjustmentsAmount: cartStore.adjustments.reduce((prev, adj) => prev + adj.amount, 0),
10075
10066
  cartId: window.Zonos.cartId,
@@ -10095,6 +10086,20 @@ const stripeStoreInitCheckoutSession = async () => {
10095
10086
  ],
10096
10087
  presentmentCountryCode: localizationStore.selectedCountryCode,
10097
10088
  };
10089
+ return body;
10090
+ };
10091
+ /**
10092
+ * Init checkout session
10093
+ * @returns {boolean} whether or not the checkout session is successfully created
10094
+ */
10095
+ const stripeStoreInitCheckoutSession = async () => {
10096
+ var _a;
10097
+ if (!localizationStore.targetCurrency) {
10098
+ handleFetch.logError(`Failed to create checkout session - missing localizationStore.targetCurrency`);
10099
+ return false;
10100
+ }
10101
+ stripeStore.isFetchingSession = true;
10102
+ const body = getCheckoutSessionBody();
10098
10103
  handleFetch.log('Checkout session body', 'info', body);
10099
10104
  const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/create-checkout-session', {
10100
10105
  body,
@@ -10110,7 +10115,7 @@ const stripeStoreInitCheckoutSession = async () => {
10110
10115
  cartStoreSetCheckoutSession(result);
10111
10116
  stripeStore.clientSecret = result.clientSecret;
10112
10117
  cartStoreApplySubtotals({
10113
- method: ((_b = result.landedCost) === null || _b === void 0 ? void 0 : _b.method) || 'DDP',
10118
+ method: ((_a = result.landedCost) === null || _a === void 0 ? void 0 : _a.method) || 'DDP',
10114
10119
  subtotals: result.subtotals,
10115
10120
  });
10116
10121
  handleFetch.log('Exchange rate updated for cart items (checkout session create)', 'info', cartStore.exchangeRate);
@@ -10689,6 +10694,7 @@ exports.currencyConvert = currencyConvert;
10689
10694
  exports.currencyConvertAndFormat = currencyConvertAndFormat;
10690
10695
  exports.currencyDisplay = currencyDisplay;
10691
10696
  exports.currencyFormat = currencyFormat;
10697
+ exports.getCheckoutSessionBody = getCheckoutSessionBody;
10692
10698
  exports.getFallbackDefaultCountryCode = getFallbackDefaultCountryCode;
10693
10699
  exports.getZCountryUrlParam = getZCountryUrlParam;
10694
10700
  exports.initLocalizationStore = initLocalizationStore;
@@ -181,7 +181,11 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
181
181
  };
182
182
  const getResponseBody = async ({ response, shouldLog = true, shouldThrow = false, }) => {
183
183
  try {
184
- const json = await response.json();
184
+ const text = await response.text();
185
+ const json = jsonParse(text);
186
+ if (!json) {
187
+ throw new Error(`Failed to parse content: ${text}`);
188
+ }
185
189
  return json;
186
190
  }
187
191
  catch (e) {
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const handleFetch = require('./handleFetch-83c97d08.js');
6
- const CheckoutConfig = require('./CheckoutConfig-00c7333a.js');
5
+ const handleFetch = require('./handleFetch-fa0ce321.js');
6
+ const CheckoutConfig = require('./CheckoutConfig-8e3cdcb3.js');
7
7
 
8
8
  /**
9
9
  * Get the load version and url based on the loadScriptSrc and version
@@ -97,7 +97,7 @@ const getZonosQaUrl = () => {
97
97
  return null;
98
98
  }
99
99
  const qaUrl = extractZonosQaUrl(window.location.href);
100
- const cdnUrl = "https://v1.3.122.js.zonos.com";
100
+ const cdnUrl = "https://v1.3.124.js.zonos.com";
101
101
  // when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
102
102
  if (!qaUrl &&
103
103
  (cdnUrl.includes('test.') ||
@@ -281,10 +281,10 @@ const zonosLoadUrl = (() => {
281
281
  }
282
282
  return null;
283
283
  })();
284
- const ZONOS_URL = "https://v1.3.122.js.zonos.com";
285
- const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.122";
286
- const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.122";
287
- const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.122";
284
+ const ZONOS_URL = "https://v1.3.124.js.zonos.com";
285
+ const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.124";
286
+ const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.124";
287
+ const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.124";
288
288
  const INTER_FONT_URL = 'https://rsms.me';
289
289
  const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
290
290
  const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
@@ -299,7 +299,7 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
299
299
  !!window.location.search.match(/\?.*(&*)zonosConversionTest/);
300
300
  Zonos._paypalMockResponse = null;
301
301
  Zonos.isBigCommerce = false;
302
- Zonos.releaseDate = "1730912119121";
302
+ Zonos.releaseDate = "1730994388117";
303
303
  Zonos.isLegacyCheckout = false;
304
304
  Zonos.showBaseForeign = typeof window !== 'undefined' &&
305
305
  window.location.search.includes('zonosShowBaseForeign');
@@ -309,7 +309,7 @@ Zonos.showBaseForeign = typeof window !== 'undefined' &&
309
309
  Zonos.isNpm = true;
310
310
  Zonos.zonosQaUrl = null;
311
311
  Zonos.zonosQaUrlApi = null;
312
- Zonos.version = `v${"1.3.122"}`;
312
+ Zonos.version = `v${"1.3.124"}`;
313
313
  Zonos.modeAlerted = false;
314
314
  Zonos.cartData = null;
315
315
  Zonos.paypal = null;
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  const zonosStore = require('./zonosStore-e12d459c.js');
4
- const cart = require('./cart-0e01d134.js');
5
- const handleFetch = require('./handleFetch-83c97d08.js');
4
+ const cart = require('./cart-a2a94f35.js');
5
+ const handleFetch = require('./handleFetch-fa0ce321.js');
6
6
  const isDarkColor = require('./isDarkColor-d206c6fa.js');
7
7
 
8
8
  /*!
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-0e01d134.js');
6
+ const cart = require('./cart-a2a94f35.js');
7
7
  const isCheckoutMobile = require('./isCheckoutMobile-f491ca7c.js');
8
- const handleFetch = require('./handleFetch-83c97d08.js');
8
+ const handleFetch = require('./handleFetch-fa0ce321.js');
9
9
  const containsNonLatinChars = require('./containsNonLatinChars-2be5129b.js');
10
10
  const zonosStore = require('./zonosStore-e12d459c.js');
11
11
  const classes = require('./classes-b7918f56.js');
@@ -3,13 +3,13 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-0e01d134.js');
6
+ const cart = require('./cart-a2a94f35.js');
7
7
  const classes = require('./classes-b7918f56.js');
8
- const paypal = require('./paypal-f1366d51.js');
8
+ const paypal = require('./paypal-bf7d3c50.js');
9
9
  const zonosStore = require('./zonosStore-e12d459c.js');
10
10
  const createCustomEvent = require('./createCustomEvent-3e982e57.js');
11
11
  const getBorderRadius = require('./getBorderRadius-61ed5601.js');
12
- const handleFetch = require('./handleFetch-83c97d08.js');
12
+ const handleFetch = require('./handleFetch-fa0ce321.js');
13
13
  const isCheckoutMobile = require('./isCheckoutMobile-f491ca7c.js');
14
14
  const ILanguage = require('./ILanguage-98b04442.js');
15
15
  const isDarkColor = require('./isDarkColor-d206c6fa.js');
@@ -3,16 +3,16 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-0e01d134.js');
7
- const paypal = require('./paypal-f1366d51.js');
6
+ const cart = require('./cart-a2a94f35.js');
7
+ const paypal = require('./paypal-bf7d3c50.js');
8
8
  const zonosStore = require('./zonosStore-e12d459c.js');
9
- const handleFetch = require('./handleFetch-83c97d08.js');
9
+ const handleFetch = require('./handleFetch-fa0ce321.js');
10
10
  const createCustomEvent = require('./createCustomEvent-3e982e57.js');
11
11
  const isCheckoutMobile = require('./isCheckoutMobile-f491ca7c.js');
12
12
  const classes = require('./classes-b7918f56.js');
13
13
  const getBorderRadius = require('./getBorderRadius-61ed5601.js');
14
14
  const isDarkColor = require('./isDarkColor-d206c6fa.js');
15
- const CheckoutConfig = require('./CheckoutConfig-00c7333a.js');
15
+ const CheckoutConfig = require('./CheckoutConfig-8e3cdcb3.js');
16
16
  const RemoveIcon = require('./RemoveIcon-081ac073.js');
17
17
 
18
18
  /**
@@ -534,6 +534,7 @@ const ZonosCheckout = class {
534
534
  metadata: {
535
535
  allLogs: handleFetch.allLogs,
536
536
  cartId: window.Zonos.cartId,
537
+ checkoutSessionBody: cart.getCheckoutSessionBody(),
537
538
  href: window.location.href,
538
539
  storeBaseUrl: (_a = window.Zonos.cartData) === null || _a === void 0 ? void 0 : _a.storeBaseUrl,
539
540
  },
@@ -3,9 +3,9 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-0e01d134.js');
6
+ const cart = require('./cart-a2a94f35.js');
7
7
  const zonosStore = require('./zonosStore-e12d459c.js');
8
- const handleFetch = require('./handleFetch-83c97d08.js');
8
+ const handleFetch = require('./handleFetch-fa0ce321.js');
9
9
  require('./isDarkColor-d206c6fa.js');
10
10
  require('./getBorderRadius-61ed5601.js');
11
11
 
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-0e01d134.js');
6
+ const cart = require('./cart-a2a94f35.js');
7
7
  const zonosStore = require('./zonosStore-e12d459c.js');
8
8
  const classes = require('./classes-b7918f56.js');
9
- require('./handleFetch-83c97d08.js');
9
+ require('./handleFetch-fa0ce321.js');
10
10
  require('./isDarkColor-d206c6fa.js');
11
11
  require('./getBorderRadius-61ed5601.js');
12
12
 
@@ -3,12 +3,12 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-0e01d134.js');
6
+ const cart = require('./cart-a2a94f35.js');
7
7
  const zonosStore = require('./zonosStore-e12d459c.js');
8
8
  const formatStringWithLinks = require('./formatStringWithLinks-52341fc7.js');
9
9
  const isDarkColor = require('./isDarkColor-d206c6fa.js');
10
10
  const ILanguage = require('./ILanguage-98b04442.js');
11
- require('./handleFetch-83c97d08.js');
11
+ require('./handleFetch-fa0ce321.js');
12
12
  require('./getBorderRadius-61ed5601.js');
13
13
 
14
14
  /**
@@ -3,12 +3,12 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-0e01d134.js');
6
+ const cart = require('./cart-a2a94f35.js');
7
7
  const zonosStore = require('./zonosStore-e12d459c.js');
8
8
  const classes = require('./classes-b7918f56.js');
9
9
  const formatStringWithLinks = require('./formatStringWithLinks-52341fc7.js');
10
10
  const getHasMoreSpaceOnRight = require('./getHasMoreSpaceOnRight-4c94667f.js');
11
- require('./handleFetch-83c97d08.js');
11
+ require('./handleFetch-fa0ce321.js');
12
12
  require('./isDarkColor-d206c6fa.js');
13
13
  require('./getBorderRadius-61ed5601.js');
14
14
 
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
6
  const zonosStore = require('./zonosStore-e12d459c.js');
7
- const cart = require('./cart-0e01d134.js');
7
+ const cart = require('./cart-a2a94f35.js');
8
8
  const classes = require('./classes-b7918f56.js');
9
- const handleFetch = require('./handleFetch-83c97d08.js');
9
+ const handleFetch = require('./handleFetch-fa0ce321.js');
10
10
  const getHasMoreSpaceOnRight = require('./getHasMoreSpaceOnRight-4c94667f.js');
11
11
  require('./isDarkColor-d206c6fa.js');
12
12
  require('./getBorderRadius-61ed5601.js');
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-d56e0a8b.js');
6
- const cart = require('./cart-0e01d134.js');
6
+ const cart = require('./cart-a2a94f35.js');
7
7
  const zonosStore = require('./zonosStore-e12d459c.js');
8
8
  const ILanguage = require('./ILanguage-98b04442.js');
9
- require('./handleFetch-83c97d08.js');
9
+ require('./handleFetch-fa0ce321.js');
10
10
  require('./isDarkColor-d206c6fa.js');
11
11
  require('./getBorderRadius-61ed5601.js');
12
12
 
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  const index = require('./index-d56e0a8b.js');
6
6
  const zonosStore = require('./zonosStore-e12d459c.js');
7
7
  const classes = require('./classes-b7918f56.js');
8
- const cart = require('./cart-0e01d134.js');
9
- const handleFetch = require('./handleFetch-83c97d08.js');
10
- const paypal = require('./paypal-f1366d51.js');
8
+ const cart = require('./cart-a2a94f35.js');
9
+ const handleFetch = require('./handleFetch-fa0ce321.js');
10
+ const paypal = require('./paypal-bf7d3c50.js');
11
11
  require('./isDarkColor-d206c6fa.js');
12
12
  require('./getBorderRadius-61ed5601.js');
13
13
 
@@ -1,6 +1,5 @@
1
1
  import { readFileSync } from "fs";
2
- export const urlCheckOne = async ({ branch, filePath, packageVersion, }) => {
3
- const majorVersion = packageVersion === null || packageVersion === void 0 ? void 0 : packageVersion.split('.')[0];
2
+ export const urlCheckOne = async ({ filePath, packageVersion, }) => {
4
3
  const fileContent = readFileSync(filePath, { encoding: 'utf-8' });
5
4
  const zonosUrlRegexResult = fileContent.matchAll(/https:\/\/[a-zA-Z0-9-\.]+?(.js.zonos.com)/g);
6
5
  if (!zonosUrlRegexResult) {
@@ -17,7 +16,7 @@ export const urlCheckOne = async ({ branch, filePath, packageVersion, }) => {
17
16
  ];
18
17
  // these files are load file, no need to check version url here
19
18
  const excludeFiles = ['zonosBase', 'zonos', 'loadZonos'];
20
- result.forEach(([fullUrl]) => {
19
+ result.some(([fullUrl]) => {
21
20
  if (fullUrl.includes('.js.zonos.com') &&
22
21
  !excludeDomainPattern.includes(fullUrl) &&
23
22
  !excludeFiles.some(file => filePath.includes(file))) {
@@ -25,6 +24,11 @@ export const urlCheckOne = async ({ branch, filePath, packageVersion, }) => {
25
24
  const versioned =
26
25
  // @ts-ignore ts v5.5 requires target to be ES2017 to use group, but we run this in node and not in compiled version, so it should work with current target ES2017
27
26
  /(v(?<major>\d+)(?<patch>\.\d+(\-alpha\.\d+)*)*)\.*(.*?js\.zonos\.com)/g.exec(fullUrl);
27
+ // if it's the route js, no need to version as API is versionless
28
+ const isRouteUrl = fullUrl === null || fullUrl === void 0 ? void 0 : fullUrl.includes('route.js.zonos.com');
29
+ if (isRouteUrl) {
30
+ return false;
31
+ }
28
32
  if (!versioned) {
29
33
  throw new Error(`${filePath}: url in the file is not versioned for url "${fullUrl}"`);
30
34
  }
@@ -35,18 +39,6 @@ export const urlCheckOne = async ({ branch, filePath, packageVersion, }) => {
35
39
  if (!version) {
36
40
  throw new Error(`${filePath}: no version found after the regex for url "${fullUrl}"`);
37
41
  }
38
- const isRouteUrl = url.includes('route.js.zonos.com');
39
- // if it's the route js, the version would be just major version
40
- if (isRouteUrl) {
41
- if (branch === 'qa') {
42
- // qa branch is not versioned, should always use the latest version
43
- return;
44
- }
45
- if (version !== `v${majorVersion}`) {
46
- throw new Error(`[ROUTE] ${filePath}: found version (${version}) is not the expected major version (${majorVersion}) for url "${fullUrl}"`);
47
- }
48
- return;
49
- }
50
42
  if (version !== `v${packageVersion}`) {
51
43
  // now the rest would be just `js.zonos.com`, the version prefix should be full version
52
44
  throw new Error(`[CDN] ${filePath}: found version (${version}) is not the expected full version (${packageVersion}) for url "${fullUrl}"`);
@@ -1,7 +1,7 @@
1
1
  import { Fragment, h, Host, } from "@stencil/core";
2
2
  import { cartStore, cartStoreClearCheckoutInterval, cartStoreNextStep, cartStoreReset, cartStoreResetTabItems, cartStoreSetCheckoutSession, cartStoreStartCheckoutInterval, cartStoreUpdateItems, cartStoreUpdateToErrorState, } from "../../store/checkout/cart";
3
3
  import { paypalInitScript, paypalStoreHasPaypalEnabled, } from "../../store/checkout/paypal";
4
- import { initStripeElements, stripeStore, stripeStoreCleanupDomesticShippingSession, stripeStoreConfirmPayment, stripeStoreHandleInventoryCheck, stripeStoreHandleInventoryRefund, stripeStoreInitCheckoutSession, stripeStorePrefetchLandedCost, stripeStoreReset, } from "../../store/checkout/stripe";
4
+ import { getCheckoutSessionBody, initStripeElements, stripeStore, stripeStoreCleanupDomesticShippingSession, stripeStoreConfirmPayment, stripeStoreHandleInventoryCheck, stripeStoreHandleInventoryRefund, stripeStoreInitCheckoutSession, stripeStorePrefetchLandedCost, stripeStoreReset, } from "../../store/checkout/stripe";
5
5
  import { localizationStore, localizationStoreOnUpdate, } from "../../store/hello/localization";
6
6
  import { translate } from "../../store/translationStore";
7
7
  import { getZonosStoreTheme, zonosStore, } from "../../store/zonosStore";
@@ -321,6 +321,7 @@ export class ZonosCheckout {
321
321
  metadata: {
322
322
  allLogs,
323
323
  cartId: window.Zonos.cartId,
324
+ checkoutSessionBody: getCheckoutSessionBody(),
324
325
  href: window.location.href,
325
326
  storeBaseUrl: (_a = window.Zonos.cartData) === null || _a === void 0 ? void 0 : _a.storeBaseUrl,
326
327
  },
@@ -54,7 +54,7 @@ const getStripeOptions = ({ clientSecret, overrideBorderRadius, overridePrimaryC
54
54
  const themeBasedColor = primaryColor && isDarkColor(primaryColor) ? 'night' : 'flat';
55
55
  // if overrideTheme is provided, use it. Otherwise, use theme based on primary color
56
56
  const theme = overrideTheme === 'DARK' ? 'night' : 'flat';
57
- const paypalPaymenType = paypalEnabled ? ['external_paypal'] : [];
57
+ const paypalPaymentType = paypalEnabled ? ['external_paypal'] : [];
58
58
  return {
59
59
  appearance: {
60
60
  labels: 'floating',
@@ -70,7 +70,7 @@ const getStripeOptions = ({ clientSecret, overrideBorderRadius, overridePrimaryC
70
70
  }),
71
71
  },
72
72
  clientSecret,
73
- externalPaymentMethodTypes: [...paypalPaymenType],
73
+ externalPaymentMethodTypes: [...paypalPaymentType],
74
74
  locale: localizationStore.selectedLocale,
75
75
  };
76
76
  };
@@ -473,18 +473,9 @@ const stripeStoreConfirmPayment = async () => {
473
473
  }
474
474
  }
475
475
  };
476
- /**
477
- * Init checkout session
478
- * @returns {boolean} whether or not the checkout session is successfully created
479
- */
480
- const stripeStoreInitCheckoutSession = async () => {
481
- var _a, _b;
476
+ export const getCheckoutSessionBody = () => {
477
+ var _a;
482
478
  const total = cartStore.items.reduce((amount, item) => amount + item.amount * item.quantity, 0);
483
- if (!localizationStore.targetCurrency) {
484
- logError(`Failed to create checkout session - missing localizationStore.targetCurrency`);
485
- return false;
486
- }
487
- stripeStore.isFetchingSession = true;
488
479
  const body = {
489
480
  adjustmentsAmount: cartStore.adjustments.reduce((prev, adj) => prev + adj.amount, 0),
490
481
  cartId: window.Zonos.cartId,
@@ -510,6 +501,20 @@ const stripeStoreInitCheckoutSession = async () => {
510
501
  ],
511
502
  presentmentCountryCode: localizationStore.selectedCountryCode,
512
503
  };
504
+ return body;
505
+ };
506
+ /**
507
+ * Init checkout session
508
+ * @returns {boolean} whether or not the checkout session is successfully created
509
+ */
510
+ const stripeStoreInitCheckoutSession = async () => {
511
+ var _a;
512
+ if (!localizationStore.targetCurrency) {
513
+ logError(`Failed to create checkout session - missing localizationStore.targetCurrency`);
514
+ return false;
515
+ }
516
+ stripeStore.isFetchingSession = true;
517
+ const body = getCheckoutSessionBody();
513
518
  log('Checkout session body', 'info', body);
514
519
  const { errors, json } = await handleFetch('/api/zonos-elements/create-checkout-session', {
515
520
  body,
@@ -525,7 +530,7 @@ const stripeStoreInitCheckoutSession = async () => {
525
530
  cartStoreSetCheckoutSession(result);
526
531
  stripeStore.clientSecret = result.clientSecret;
527
532
  cartStoreApplySubtotals({
528
- method: ((_b = result.landedCost) === null || _b === void 0 ? void 0 : _b.method) || 'DDP',
533
+ method: ((_a = result.landedCost) === null || _a === void 0 ? void 0 : _a.method) || 'DDP',
529
534
  subtotals: result.subtotals,
530
535
  });
531
536
  log('Exchange rate updated for cart items (checkout session create)', 'info', cartStore.exchangeRate);
@@ -16,7 +16,11 @@ import { log } from "./logging/log";
16
16
  import { sendErrorLog } from "./logging/sendErrorLog";
17
17
  const getResponseBody = async ({ response, shouldLog = true, shouldThrow = false, }) => {
18
18
  try {
19
- const json = await response.json();
19
+ const text = await response.text();
20
+ const json = jsonParse(text);
21
+ if (!json) {
22
+ throw new Error(`Failed to parse content: ${text}`);
23
+ }
20
24
  return json;
21
25
  }
22
26
  catch (e) {
@@ -1,4 +1,4 @@
1
- import { h as handleFetch, l as log, a as logError } from './handleFetch-7424d200.js';
1
+ import { h as handleFetch, l as log, a as logError } from './handleFetch-da1a9c5d.js';
2
2
 
3
3
  const getTempCartById = async ({ cartId, retries, }) => {
4
4
  const urlParams = new URLSearchParams(window.location.search);
@@ -1,5 +1,5 @@
1
1
  import { c as createStore, z as zonosStore } from './zonosStore-6b5bd87c.js';
2
- import { h as handleFetch, a as logError, l as log, f as fallbackApiList, s as sendErrorLog, j as jsonParse } from './handleFetch-7424d200.js';
2
+ import { h as handleFetch, a as logError, l as log, f as fallbackApiList, s as sendErrorLog, j as jsonParse } from './handleFetch-da1a9c5d.js';
3
3
  import { i as isDarkColor } from './isDarkColor-dc08fa26.js';
4
4
  import { g as getBorderRadius } from './getBorderRadius-008516a4.js';
5
5
 
@@ -9638,7 +9638,7 @@ const getStripeOptions = ({ clientSecret, overrideBorderRadius, overridePrimaryC
9638
9638
  const themeBasedColor = primaryColor && isDarkColor(primaryColor) ? 'night' : 'flat';
9639
9639
  // if overrideTheme is provided, use it. Otherwise, use theme based on primary color
9640
9640
  const theme = overrideTheme === 'DARK' ? 'night' : 'flat';
9641
- const paypalPaymenType = paypalEnabled ? ['external_paypal'] : [];
9641
+ const paypalPaymentType = paypalEnabled ? ['external_paypal'] : [];
9642
9642
  return {
9643
9643
  appearance: {
9644
9644
  labels: 'floating',
@@ -9653,7 +9653,7 @@ const getStripeOptions = ({ clientSecret, overrideBorderRadius, overridePrimaryC
9653
9653
  colorPrimary: secondaryColor }),
9654
9654
  },
9655
9655
  clientSecret,
9656
- externalPaymentMethodTypes: [...paypalPaymenType],
9656
+ externalPaymentMethodTypes: [...paypalPaymentType],
9657
9657
  locale: localizationStore.selectedLocale,
9658
9658
  };
9659
9659
  };
@@ -10056,18 +10056,9 @@ const stripeStoreConfirmPayment = async () => {
10056
10056
  }
10057
10057
  }
10058
10058
  };
10059
- /**
10060
- * Init checkout session
10061
- * @returns {boolean} whether or not the checkout session is successfully created
10062
- */
10063
- const stripeStoreInitCheckoutSession = async () => {
10064
- var _a, _b;
10059
+ const getCheckoutSessionBody = () => {
10060
+ var _a;
10065
10061
  const total = cartStore.items.reduce((amount, item) => amount + item.amount * item.quantity, 0);
10066
- if (!localizationStore.targetCurrency) {
10067
- logError(`Failed to create checkout session - missing localizationStore.targetCurrency`);
10068
- return false;
10069
- }
10070
- stripeStore.isFetchingSession = true;
10071
10062
  const body = {
10072
10063
  adjustmentsAmount: cartStore.adjustments.reduce((prev, adj) => prev + adj.amount, 0),
10073
10064
  cartId: window.Zonos.cartId,
@@ -10093,6 +10084,20 @@ const stripeStoreInitCheckoutSession = async () => {
10093
10084
  ],
10094
10085
  presentmentCountryCode: localizationStore.selectedCountryCode,
10095
10086
  };
10087
+ return body;
10088
+ };
10089
+ /**
10090
+ * Init checkout session
10091
+ * @returns {boolean} whether or not the checkout session is successfully created
10092
+ */
10093
+ const stripeStoreInitCheckoutSession = async () => {
10094
+ var _a;
10095
+ if (!localizationStore.targetCurrency) {
10096
+ logError(`Failed to create checkout session - missing localizationStore.targetCurrency`);
10097
+ return false;
10098
+ }
10099
+ stripeStore.isFetchingSession = true;
10100
+ const body = getCheckoutSessionBody();
10096
10101
  log('Checkout session body', 'info', body);
10097
10102
  const { errors, json } = await handleFetch('/api/zonos-elements/create-checkout-session', {
10098
10103
  body,
@@ -10108,7 +10113,7 @@ const stripeStoreInitCheckoutSession = async () => {
10108
10113
  cartStoreSetCheckoutSession(result);
10109
10114
  stripeStore.clientSecret = result.clientSecret;
10110
10115
  cartStoreApplySubtotals({
10111
- method: ((_b = result.landedCost) === null || _b === void 0 ? void 0 : _b.method) || 'DDP',
10116
+ method: ((_a = result.landedCost) === null || _a === void 0 ? void 0 : _a.method) || 'DDP',
10112
10117
  subtotals: result.subtotals,
10113
10118
  });
10114
10119
  log('Exchange rate updated for cart items (checkout session create)', 'info', cartStore.exchangeRate);
@@ -10671,4 +10676,4 @@ const cartStoreResetTabItems = () => {
10671
10676
  cartStoreResetSelectedShippingOption();
10672
10677
  };
10673
10678
 
10674
- export { isValidSelector as A, initLocalizationStore as B, setZCountryUrlParam as C, currencyDisplay as D, currencyConvertAndFormat as E, currencyConvert as F, currencyFormat as G, cartStoreHasOneEligibleItem as H, stripeStoreApplyPromoCode as I, stripeStoreRemovePromoCode as J, stripeStoreRetrievePayment as K, stripeStoreResetPromoCode as L, stripeStoreMessageBasedOnStatus as M, stripeStoreTranslateAddressToLatin as N, cartStoreUpdateSelectedShippingOption as O, cartStoreGetShippingTransitInfo as P, sortServiceLevelOptionsByAmount as Q, getFallbackDefaultCountryCode as R, localizationStoreUpdateSelectedLocale as S, localizationStoreUpdateSelectedCountryCode as a, stripeStoreCleanupDomesticShippingSession as b, stripeStoreSaveDomesticShippingSession as c, cartStore as d, cartStoreUpdateItems as e, cartStoreReset as f, cartStoreResetTabItems as g, cartStoreClearCheckoutInterval as h, initStripeElements as i, stripeStore as j, stripeStoreInitCheckoutSession as k, localizationStore as l, cartStoreStartCheckoutInterval as m, cartStoreUpdateToErrorState as n, translate as o, getZCountryUrlParam as p, cartStoreSetCheckoutSession as q, stripeStorePrefetchLandedCost as r, stripeStoreGetDomesticShippingSession as s, trackConversionEvent as t, cartStoreNextStep as u, stripeStoreHandleInventoryCheck as v, stripeStoreConfirmPayment as w, stripeStoreHandleInventoryRefund as x, stripeStoreReset as y, localizationStoreOnUpdate as z };
10679
+ export { localizationStoreOnUpdate as A, isValidSelector as B, initLocalizationStore as C, setZCountryUrlParam as D, currencyDisplay as E, currencyConvertAndFormat as F, currencyConvert as G, currencyFormat as H, cartStoreHasOneEligibleItem as I, stripeStoreApplyPromoCode as J, stripeStoreRemovePromoCode as K, stripeStoreRetrievePayment as L, stripeStoreResetPromoCode as M, stripeStoreMessageBasedOnStatus as N, stripeStoreTranslateAddressToLatin as O, cartStoreUpdateSelectedShippingOption as P, cartStoreGetShippingTransitInfo as Q, sortServiceLevelOptionsByAmount as R, getFallbackDefaultCountryCode as S, localizationStoreUpdateSelectedLocale as T, localizationStoreUpdateSelectedCountryCode as a, stripeStoreCleanupDomesticShippingSession as b, stripeStoreSaveDomesticShippingSession as c, cartStore as d, cartStoreUpdateItems as e, cartStoreReset as f, cartStoreResetTabItems as g, cartStoreClearCheckoutInterval as h, initStripeElements as i, stripeStore as j, stripeStoreInitCheckoutSession as k, localizationStore as l, cartStoreStartCheckoutInterval as m, getCheckoutSessionBody as n, cartStoreUpdateToErrorState as o, translate as p, getZCountryUrlParam as q, cartStoreSetCheckoutSession as r, stripeStoreGetDomesticShippingSession as s, trackConversionEvent as t, stripeStorePrefetchLandedCost as u, cartStoreNextStep as v, stripeStoreHandleInventoryCheck as w, stripeStoreConfirmPayment as x, stripeStoreHandleInventoryRefund as y, stripeStoreReset as z };
@@ -179,7 +179,11 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
179
179
  };
180
180
  const getResponseBody = async ({ response, shouldLog = true, shouldThrow = false, }) => {
181
181
  try {
182
- const json = await response.json();
182
+ const text = await response.text();
183
+ const json = jsonParse(text);
184
+ if (!json) {
185
+ throw new Error(`Failed to parse content: ${text}`);
186
+ }
183
187
  return json;
184
188
  }
185
189
  catch (e) {